package com.company.exam4;
/**
 * split拆分用法
 */

import java.util.Arrays;

public class other {
    public static void main(String[] args) {
        // 按空格拆分
        String str = "java cpp php c# objective-c";
        String[] strArr = str.split("\\s");
        System.out.println(Arrays.toString(strArr));//[java, cpp, php, c#, objective-c]
        // 按+、-、=符号拆分String line = "100+200-150=150";
        String line = "100+200-150=150";
        strArr = line.split("[\\+\\-=]");
        System.out.println(Arrays.toString(strArr));//[100, 200, 150, 150]

        String str2 = "1,2,3,4,5,6";
        String[] strarr2 = str2.split(",");
        System.out.println(strarr2); //["1","2","3","4","5","6"]
    }
}
